<template lang=pug>
    div
        div.lineTwo
            search-input.searchInput(:commitFunctionName="'updateShopList'",:searchUrl="'/good/getMyRentalShop'",:keyName="'shopSearchKey'",:searchKeyFunctionName="'updateShopSearchKey'")
            router-link(to="/publish") 发布
        vProduct(v-for="item in $store.state.shopList",:product="item",:key="item.ej_good_id")
        vFooter
</template>

<script type="es6">
    import searchInput from '../common/searchInput.vue'
    import publish from './publish.vue'
    import vProduct from './product.vue'
    import vFooter from '../common/footer/footer.vue'


    export default {
        name: 'shop',
        data () {
            return {
                pageNumber:1,
                state:'normal',
                fleshState:'canReflesh'
            }
        },
        mounted (){
            var self = this
            console.log(this)
            this.$http.get('/good/getMyRentalShop',{
                params:{
                    pageSize:10,
                    pageNumber:self._data.pageNumber,
                    key:this.$store.state.shopSearchKey
                }
            }).then(response=>{
                this.$store.commit('updateShopList',response.data.data.list)
                console.log('shopList=',response.data.data.list)
            }).catch(error=> {
                console.log(error);
                this.$store.commit('updateShopList',  [])
            })


//            this.$http.axios.post('/user', {
//                firstName: 'Fred',
//                lastName: 'Flintstone'
//            })
//            function getUserAccount() {
//                return axios.get('/user/12345');
//            }
//
//            function getUserPermissions() {
//                return axios.get('/user/12345/permissions');
//            }
//
//            axios.all([getUserAccount(), getUserPermissions()])
//                .then(axios.spread(function (acct, perms) {
//                    // Both requests are now complete
//                }));
        },
        components: {
            searchInput,
            publish,
            vProduct,
            vFooter
        }
    }
</script>

<style lang="stylus" scoped>
    .lineTwo
        display flex

</style>
